#include "animal.h"

// 实现类型注册
G_DEFINE_TYPE(MyAnimal, my_animal, G_TYPE_OBJECT)

// 默认发声实现
static void my_animal_speak_default(MyAnimal *self) {
    g_print("(Animal) ???\n");
}

// 类初始化
static void my_animal_class_init(MyAnimalClass *klass) {
    klass->speak = my_animal_speak_default;
}

// 实例初始化
static void my_animal_init(MyAnimal *self) {}

// 公开API
void my_animal_speak(MyAnimal *self) {
    g_return_if_fail(MY_IS_ANIMAL(self));
    MyAnimalClass *klass = MY_ANIMAL_GET_CLASS(self);
    klass->speak(self);
}